package com.lagou.homeWork4.hw1;
/*
* 第一题后续：读取文件
* */

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.List;

public class ReadList {
    @SuppressWarnings("unchecked")
    public static List<Student> readList() {
        ObjectInputStream in = null;
        List<Student> listStudents =null;
        try {
            in = new ObjectInputStream(new FileInputStream("./lagouhomeWork4/hw1/listStudents.txt"));
            // 读取文件
            Object obj = in.readObject();
            // 获取集合对象
            listStudents = (List<Student>)obj;
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        } finally {
            if (null != null) {
                try {
                    in.close();

                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        // 返回集合对象
        return listStudents;
    }
}
